package com.chenyongjing.design.pattern.singleton.LazyStaticInnerClassSingleton;

import java.lang.reflect.Constructor;

/**
 * 反射破坏静态内部类方式的懒加载
 */
public class RejectTest {
    public static void main(String[] args) {
        try {
            Class clazz  =  LazystaticInnerClassSingleton.class;
            Constructor c = clazz.getDeclaredConstructor(null);
            // 强制设置可访问
            c.setAccessible(true);
            // 创建两个对象
            Object instance1 = c.newInstance();
            Object instance2 = c.newInstance();

            System.out.println(instance1);
            System.out.println(instance2);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
